<?php
header ( "Content-Type: text/html; charset=utf-8" );
error_reporting ( 7 );
ini_set ( "memory_limit", "128M" );
date_default_timezone_set ( 'Asia/Shanghai' );
set_include_path ( '.' . PATH_SEPARATOR . '../library' . PATH_SEPARATOR . '../library/incubator' . PATH_SEPARATOR . '../application/default/models' . PATH_SEPARATOR . get_include_path () );
include "Zend/Loader.php";
function __autoload($class) {
	Zend_Loader::autoload ( $class );
}
//$frontendOptions = array ('lifeTime' => 7200, 'automatic_serialization' => true );
//$backendOptions = array ('cache_dir' => './cache/' );
//$cache = Zend_Cache::factory ( 'Core', 'File', $frontendOptions, $backendOptions );
//Zend_Db_Table_Abstract::setDefaultMetadataCache ( $cache );
//Zend_Registry::set ( "cache", $cache );
//
//Zend_Debug::dump($_SERVER);


$configArray = array ('db' => array (//
'adapter' => 'PDO_MYSQL', //
'config' => array (//
'host' => 'localhost', //
'username' => 'h183076', //
'password' => '13920612255', //
'dbname' => 'dbh183076', //
'profiler' => true ), //
'charset' => 'utf8' ) );
$config = new Zend_Config ( $configArray );

$db = Zend_Db::factory ( $config->db->adapter, $config->db->config->toArray () );
$db->query ( "set names {$config->db->charset};" );
Zend_Db_Table::setDefaultAdapter ( $db );
Zend_Registry::set ( 'db', $db );
//
$sess = array ('name' => 'bc_session', //table name as per Zend_Db_Table
'primary' => array ('session_id', //php   sessionID  
'save_path', //session.save_path
'name' ), 'primaryAssignment' => array ('sessionId', //  sessionID
'sessionSavePath', 'sessionName' ), 'modifiedColumn' => 'modified', //time of the last modification of the session
'dataColumn' => 'session_data', //serialized data
'lifetimeColumn' => 'lifetime' ); //lifetime for a specific record
Zend_Session::setSaveHandler ( new Zend_Session_SaveHandler_DbTable ( $sess ) );
Zend_Session::start ();

include ('../library/My/xml.php'); //
$config = array ('auth' => 'login', 'username' => '2012728', 'password' => '315162' );
$tr = new Zend_Mail_Transport_Smtp ( 'smtp.qq.com', $config );
Zend_Mail::setDefaultTransport ( $tr );
//Zend_Layout::startMvc ( array ('layoutPath' => './application/views/layouts' ) );
//$auth = Zend_Auth::getInstance ();
// setup controller
$frontController = Zend_Controller_Front::getInstance ();
$frontController->setControllerDirectory ( array ('default' => '../application/default/controllers', 'admin' => '../application/admin/controllers' ) );
$router = $frontController->getRouter ();
$router->addRoute ( 'goods_view', new Zend_Controller_Router_Route_Regex ( 'g(\d+).html', array ('controller' => 'goods', 'action' => 'view' ), array (1 => id ) ) );
$router->addRoute ( 'articles_view', new Zend_Controller_Router_Route_Regex ( 'a(\d+).html', array ('controller' => 'articles', 'action' => 'view' ), array (1 => id ) ) );
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper ( 'viewRenderer' );
$viewRenderer->setViewSuffix ( 'php' );
$frontController->registerPlugin ( new MyPlugin ( ) );

//die ();
try {
	$frontController->dispatch ( $request, $response );
} catch ( Exception $dispatch_exception ) {
	$request = new Zend_Controller_Request_Http ( );
	$request->setRequestUri ( '/error/error' );
	
	$response = new Zend_Controller_Response_Http ( );
	
	$frontController->dispatch ( $request, $response );
}
